package com.aiq.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @ClassName: SwaggerConfig
 * @Description: 启用Swagger
 * @Author: vie0134
 * @Date: 2021-01-11 18:05
 * @Version: 1.0
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * @Author: vie0134
     * @Description:  构建文档的基本信息
     * @Date: 18:07 2021/1/11
     * @return: ApiInfo
     */
    public ApiInfo createApi(){
        return new ApiInfoBuilder().description("AiQ项目的接口在线文档")
                .title("AiQ接口文档").contact(new Contact("AiQ","https://gitee.com/tiami/love-song.git","huw0134@aliyun.com"))
                .version("1.0").build();
    }

    /**
     * @Author: vie0134
     * @Description:  就是ioc创建实例 修饰方法 方法必须返回对象
     * @Date: 18:08 2021/1/11
     * @return: Docket
     */
    @Bean
    public Docket createDocket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApi())
                .select().apis(RequestHandlerSelectors.basePackage("com.aiq.controller")).build();
    }
}
